package com.guigusuqi.hy.controller;

import com.guigusuqi.app.entity.LoginWxUser;
import com.guigusuqi.app.entity.WxUser;
import com.guigusuqi.commonutils.utils.GetTokenByAuthorizationUtils;
import com.guigusuqi.commonutils.utils.RedisCache;
import com.guigusuqi.commonutils.vo.Result;
import com.guigusuqi.hy.dto.Referral;
import com.guigusuqi.hy.entity.Recommend;
import com.guigusuqi.hy.service.RecommendService;
import com.guigusuqi.hy.vo.RecommendVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;

/**
 * <p>
 * 新人推荐管理 前端控制器
 * </p>
 *
 * @author suqi
 * @since 2022-04-19
 */
@RestController
@RequestMapping("/hy/recommend")
@Api(tags = {"wx-老带新管理"})
public class RecommendController
{
    @Resource
    private RecommendService recommendService;

    @PostMapping("recommendNew")
    @ApiOperation("用户推荐新人")
    public Result recommendNew(@RequestBody(required = true) Referral referral) throws IOException
    {
        return recommendService.RecommendNew(referral);
    }

    @GetMapping("recommendList")
    @ApiOperation("查询推荐了哪些人")
    public Result recommendList() throws IOException
    {
        List<RecommendVo> recommendVos = recommendService.recommendList();
        return Result.success().data("rows",recommendVos);
    }

    @GetMapping("referralList")
    @ApiOperation("查询被哪些人推荐")
    public Result referralList() throws IOException
    {
        return recommendService.referralList();
    }
}

